namespace LabChecker.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class InitialMigration : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "Users",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        FirstName = c.String(nullable: false, maxLength: 4000),
                        LastName = c.String(nullable: false, maxLength: 4000),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "Groups",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 4000),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "InternalLogins",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Email = c.String(nullable: false, maxLength: 4000),
                        PasswordHash = c.String(nullable: false, maxLength: 4000),
                        User_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("Users", t => t.User_Id, cascadeDelete: true)
                .Index(t => t.User_Id);
            
            CreateTable(
                "Students",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        Group_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("Users", t => t.Id)
                .ForeignKey("Groups", t => t.Group_Id, cascadeDelete: true)
                .Index(t => t.Id)
                .Index(t => t.Group_Id);
            
        }
        
        public override void Down()
        {
            DropIndex("Students", new[] { "Group_Id" });
            DropIndex("Students", new[] { "Id" });
            DropIndex("InternalLogins", new[] { "User_Id" });
            DropForeignKey("Students", "Group_Id", "Groups");
            DropForeignKey("Students", "Id", "Users");
            DropForeignKey("InternalLogins", "User_Id", "Users");
            DropTable("Students");
            DropTable("InternalLogins");
            DropTable("Groups");
            DropTable("Users");
        }
    }
}
